﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpXML
{
    public class XMLRoot : XMLElement
    {
        
        public XMLRoot(string xml) : base(xml)
        {
            if (xml.Substring(0, 2) == "<?" && xml.IndexOf("?>") > 0) xml = xml.Substring(xml.IndexOf("?>") + 2);
            this._innerXml = xml.Trim();
        }

        public override int Length
        {
            get
            {
                int length = 0;
                if (_Children != null)
                {
                    foreach (XMLElement child in _Children) length += child.Length;
                    length += _text.Length;
                }
                else length += _innerXml.Length;
                return length;
            }
        }

        public override string ToString()
        {
            return innerXml;
        }
    }
}
